package com.xian.ucenter.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.json.JSONUtil;
import com.xian.ucenter.commons.Result;
import com.xian.ucenter.entities.User;
import com.xian.ucenter.entities.vo.UserInfo;
import com.xian.ucenter.entities.vo.UserLogin;
import com.xian.ucenter.mapper.UserMapper;
import com.xian.ucenter.service.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xian.ucenter.utils.ConstantUtil;
import com.xian.ucenter.utils.JwtUtil;
import com.xian.ucenter.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Objects;
import java.util.concurrent.TimeUnit;

/**
 * <p>
 * 用户管理表 服务实现类
 * </p>
 *
 * @author xian
 * @since 2022/07/23 03:15
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Value("${blog.userId}")
    private String userId;
    @Override
    public UserInfo getUserInfo() {
        return BeanUtil.copyProperties(userMapper.selectById(userId), UserInfo.class);
    }

    @Override
    public boolean addUser(User user) {
        return userMapper.insert(user) > 0;
    }
}
